<template>
  <div class="app-container">
    <el-row :gutter="20" type="flex">
      <el-col style="width: 260px;">
        <pointListMore ref="pointPlugin"></pointListMore>
      </el-col>
      <el-col>
        <el-card class="box-card" :style="{height: tabHt+'px'}">
          <el-form ref="form" :model="form" :rules="rules" label-width="80px" style="width: 800px;">
            <el-row>
              <el-col :span="4">
                <el-form-item>
                  <el-button type="primary" @click="downAllDev" style="width: 100px;height: 100px;border-radius:50px;" >全部更新</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <el-button type="primary" @click="downSelDev" style="width: 100px;height: 100px;border-radius:50px;" >选站更新</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <el-button type="primary" @click="downTakeEffectDev" style="width: 100px;height: 100px;border-radius:50px;" >更新生效</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <el-button type="primary" @click="downSaveDev" style="width: 100px;height: 100px;border-radius:50px;" >保存配置</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <el-button type="primary" @click="downRestoreDev" style="width: 100px;height: 100px;border-radius:50px;" >还原配置</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="信息记录" >
                  <el-input type="textarea" :rows="15" v-model="msg" readonly  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-card>
      </el-col>
    </el-row>

  </div>
</template>

<script>
  import { downAllDev,downSelDev,downTakeEffectDev,downSaveDev,downRestoreDev } from "@/api/basic/collectPoint";
  import pointListMore from "@/views/components/pointListMore";

  export default {
    name: "DutyDeviceSet",
    components: { pointListMore },
    data() {
      return {
        msg:'',
        pointId:null,
        // 表单参数
        form: {
        },
        // 表单校验
        rules: {
        }
      };
    },
    computed: {
      tabHt(){
        return this.$store.state.app.tableHeight.pointHt
      }
    },
    created() {
    },
    methods: {
      downAllDev(){
        downAllDev().then(res => {
          if(res.data.success){
            this.msgSuccess(res.data.infoMsg);
          }else{
            this.msgError(res.data.infoMsg);
          }
          this.msg = res.data.msg +'\n'+ this.msg;
        });
      },
      downSelDev(){
        let pointIds = this.$refs['pointPlugin'].getPointIds();
        if(pointIds.length===0){
          this.msgError("请选择站点！！")
          return;
        }
        downSelDev({pointIds:pointIds.join(',')}).then(res => {
          if(res.data.success){
            this.msgSuccess(res.data.infoMsg);
          }else{
            this.msgError(res.data.infoMsg);
          }
          this.msg = res.data.msg +'\n'+ this.msg;
        });
      },
      downTakeEffectDev(){
        downTakeEffectDev().then(res => {
          if(res.data.success){
            this.msgSuccess(res.data.infoMsg);
          }else{
            this.msgError(res.data.infoMsg);
          }
          this.msg = res.data.msg +'\n'+ this.msg;
        });
      },
      downSaveDev(){
        downSaveDev().then(res => {
          if(res.data.success){
            this.msgSuccess(res.data.infoMsg);
          }else{
            this.msgError(res.data.infoMsg);
          }
          this.msg = res.data.msg +'\n'+ this.msg;
        });
      },
      downRestoreDev(){
        downRestoreDev().then(res => {
          if(res.data.success){
            this.msgSuccess(res.data.infoMsg);
          }else{
            this.msgError(res.data.infoMsg);
          }
          this.msg = res.data.msg +'\n'+ this.msg;
        });
      },
      handlePointClick(obj){
        this.pointId = obj.pointId;
      },
    }
  };
</script>
